﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ViewUsers.aspx.cs" Inherits="TRL.TRLAdmin.UserMgmt.ViewUsers" Trace="false" %>
<%@ Register TagPrefix="uc" TagName="ConfirmDeleteModal" Src="ConfirmDeleteModal.ascx" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <nav>
        <div id="jCrumbs" class="breadCrumb module">
            <ul>
                <li>
                    <a href="#"><i class="icon-home"></i></a>
                </li>
                <li>
                    Admin User Management
                </li>
                <li>
                    View Admin Users
                </li>
            </ul>
        </div>
    </nav>

    <div class="page-header">
        <h1>View\Edit Admin Users</h1>
    </div>
    
    <div class="row-fluid">
    <div class="span12">
        <asp:GridView ID="GridView1" runat="server" DataSourceID="AdminUserSelect" CssClass="table table-striped table-condensed" BorderStyle="None" EnableViewState="false" AutoGenerateColumns="false" GridLines="None">
            <Columns>
                <asp:TemplateField HeaderText="Action">
                    <ItemTemplate>
                         <a title="Edit" href='AddEditUser.aspx?mode=edit&userId=<%# Eval("UserId") %>&userFullName=<%# Eval("fullName") %>'><i class="splashy-document_letter_edit"></i></a>
                         <a title="Delete" onclick="confirmDeleteUser('<%# Eval("UserId") %>', '<%# Eval("fullName") %>'); return false;"><i class="splashy-document_letter_remove"></i></a>
                    </ItemTemplate>
                </asp:TemplateField>    
                <asp:BoundField DataField="fullName" HeaderText="Full Name" />    
                <asp:BoundField DataField="Username" HeaderText="Username" />    
                <asp:BoundField DataField="Email" HeaderText="Email" />    
                <asp:BoundField DataField="CreateDate" DataFormatString = "{0:G}" HeaderText="Created On" />                    
                <asp:BoundField DataField="LastLoginDate" DataFormatString = "{0:G}" HeaderText="Last Login" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="AdminUserSelect" runat="server" ProviderName="System.Data.SqlClient" SelectCommand="
            -- The DATEADDs are to convert from UTC to local time.
            -- Note that if you work with the Membership Provider data using its .NET classes
            -- it'll convert the times to local time for you.
            SELECT 
                u.userId as UserId, Username, fullName, Email, 
                CASE WHEN LastLoginDate = CreateDate THEN NULL ELSE DATEADD(hh,DATEDIFF(hh,GETUTCDATE(),GETDATE()),LastLoginDate) END AS LastLoginDate, 
                DATEADD(hh,DATEDIFF(hh,GETUTCDATE(),GETDATE()),CreateDate) AS CreateDate
            FROM [dbo].[vw_aspnet_MembershipUsers] u
            LEFT JOIN AdminUserInfo au ON
                u.UserId = au.userID" ConnectionString="<%$ ConnectionStrings:trladminConnectionString %>"></asp:SqlDataSource>
    </div>
    </div>

    <uc:ConfirmDeleteModal runat="server"></uc:ConfirmDeleteModal>
</asp:Content>

    
<asp:Content ID="Content3" ContentPlaceHolderID="scripts" runat="server">
    <script type="text/javascript">
 
        $(document).ready(function () {
            // Set the sidebar orientation to the section and page 
            // of this document
            $('#collapseThree').addClass("in");
            $('#viewUsers').addClass("active");
        });

    </script>
</asp:Content>
